package com.example.demo.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author yuwc
 * @description 练习异步
 * @data 2019/5/17 0017下午 3:49
 */
@Component
public class TestAsync {
    Logger log = LoggerFactory.getLogger(TestAsync.class);

    /**发送提醒短信 */
    @Async("taskExecutor")
    public void service1() throws InterruptedException {
        log.info("--------start-service1------------");
        /**模拟耗时*/
//        Thread.sleep(5000);
        log.info("--------end-service1------------");
    }
    @Async("taskExecutor")
    public void service2() throws InterruptedException {

        log.info("--------start-service2------------");
        /**模拟耗时*/
       // Thread.sleep(2000);
        log.info("--------end-service2------------");

    }

}
